<template>
	<view class="wap">
		<navbar :parameter='parameter'></navbar>
		<image src="/static/images/user-back.jpg" mode="widthFix"
			style="position: absolute; width: 100%;left: 0;top: 0;"></image>
		<view class="user">
			<view class='header acea-row row-between-wrapper'>
				<view class="acea-row row-middle" v-if="userInfo == ''">
					<view class='pictrue' @click="chamgs">
						<image :src='userInfo.avatar'></image>
					</view>
					<view class='name' @click="chamgs">
						请点击登录
					</view>
				</view>
				<view class="acea-row row-middle" v-else>
					<view class='pictrue'>
						<image :src='userInfo.avatar'></image>
					</view>
					<view class='name'>
						{{userInfo.nickname}}
					</view>
				</view>
				<navigator @click="toSet" class="acea-row row-middle">
					<text class="iconfont icon-shezhixitongshezhigongnengshezhishuxing-xian"></text> 设置
				</navigator>
			</view>
			<view class='nav acea-row row-middle'>
				<navigator class='item' url="/pages/order/list" hover-class="none" open-type="switchTab">
					<view class='num'>{{userInfo.order_num}}</view>
					<view class="title">我的订单</view>
				</navigator>
				<navigator class='item' url="/pages/order/coupon" hover-class="none">
					<view class='num'>{{userInfo.coupon_num}}</view>
					<view class="title">优惠券</view>
				</navigator>
				<navigator class='item' :url="'/pages/user/commission?commission='+userInfo.commission"
					hover-class="none">
					<view class='num'>{{userInfo.commission}}</view>
					<view class="title">我的佣金</view>
				</navigator>
			</view>
			<view class='box myOrder'>
				<view class='title-line acea-row row-between-wrapper'>
					<view class="title-tip">我的订单</view>
					<navigator class='allOrder acea-row row-middle' url="/pages/order/list" open-type="switchTab">
						查看全部<u-icon name="arrow-right" color="#9C9C9C"></u-icon>
					</navigator>
				</view>
				<view class='acea-row row-between-wrapper'>
					<block v-for="(item,index) in order_list " :key="index">
						<view class='item' @click="toOrder(item)">
							<view class='pictrue acea-row row-center-wrapper'>
								<image :src='item.pic' mode="widthFix"></image>
							</view>
							<view class="title">{{item.title}}</view>
						</view>
					</block>
				</view>
			</view>
			<view class="box">
				<navigator class="line acea-row row-between-wrapper"
					:url="'/pages/user/patient_management?isChoice='+1">
					<view class="acea-row row-middle">
						<text class="iconfont icon-renyuan"></text>
						<view class="title">就诊人管理</view>
					</view>
					<u-icon name="arrow-right" color="#9C9C9C"></u-icon>
				</navigator>
				<navigator class="line acea-row row-between-wrapper" :url="'/pages/accompanying/center?id='+userInfo.id"
					v-if="userInfo.staff_status == 1">
					<view class="acea-row row-middle">
						<text class="iconfont icon-zhuanjia"></text>
						<view class="title">陪诊师中心</view>
						<view class="num" v-if="userInfo.staff_order_num > 0"> {{userInfo.staff_order_num}} </view>
					</view>
					<u-icon name="arrow-right" color="#9C9C9C"></u-icon>
				</navigator>
				<navigator class="line acea-row row-between-wrapper"
					:url="'/pages/user/attendant?staff_status='+userInfo.staff_status" v-else>
					<view class="acea-row row-middle">
						<text class="iconfont icon-zhuanjia"></text>
						<view class="title">我要成为陪诊师</view>
					</view>
					<u-icon name="arrow-right" color="#9C9C9C"></u-icon>
				</navigator>
				
				<navigator class="line acea-row row-between-wrapper" :url="'/bundle/pages/about/center?id='+userInfo.id" v-if="userInfo.yds_status == 1">
					<view class="acea-row row-middle">
						<text class="iconfont icon-zhuanjia"></text>
						<view class="title">应答师中心</view>
					</view>
					<u-icon name="arrow-right" color="#9C9C9C"></u-icon>
				</navigator>
				
				<view class="line acea-row row-between-wrapper" v-else-if="userInfo.yds_status == 0" @click="applyForm(1)">
					<view class="acea-row row-middle">
						<text class="iconfont icon-zhuanjia"></text>
						<view class="title">应答师申请中</view>
					</view>
					<u-icon name="arrow-right" color="#9C9C9C"></u-icon>
				</view>
				
				<view class="line acea-row row-between-wrapper" v-else-if="userInfo.yds_status == 2" @click="applyForm(2)">
					<view class="acea-row row-middle">
						<text class="iconfont icon-zhuanjia"></text>
						<view class="title">应答师申请失败</view>
					</view>
					<u-icon name="arrow-right" color="#9C9C9C"></u-icon>
				</view>
				
				<navigator class="line acea-row row-between-wrapper" :url="'/pages/user/apply_about?id='+userInfo.id" v-else>
					<view class="acea-row row-middle">
						<text class="iconfont icon-zhuanjia"></text>
						<view class="title">我要成为应答师</view>
					</view>
					<u-icon name="arrow-right" color="#9C9C9C"></u-icon>
				</navigator>
				
				
				
				<navigator class="line acea-row row-between-wrapper" :url="'/bundle/pages/birth/center?id='+userInfo.id" v-if="userInfo.fszy_status == 1">
					<view class="acea-row row-middle">
						<text class="iconfont icon-zhuanjia"></text>
						<view class="title">辅生专员中心</view>
					</view>
					<u-icon name="arrow-right" color="#9C9C9C"></u-icon>
				</navigator>
				
				<navigator class="line acea-row row-between-wrapper" :url="'/bundle/pages/clinical/center?type=1'" v-if="userInfo.syzy_status == 1">
					<view class="acea-row row-middle">
						<text class="iconfont icon-zhuanjia"></text>
						<view class="title">临床试验专员中心</view>
					</view>
					<u-icon name="arrow-right" color="#9C9C9C"></u-icon>
				</navigator>
				
				<navigator class="line acea-row row-between-wrapper" :url="'/bundle/pages/clinical/center?type=0'" v-else>
					<view class="acea-row row-middle">
						<text class="iconfont icon-zhuanjia"></text>
						<view class="title">临床试验申请订单</view>
					</view>
					<u-icon name="arrow-right" color="#9C9C9C"></u-icon>
				</navigator>

				<navigator class="line acea-row row-between-wrapper"
					:url="'/pages/user/invite_qrcode?avatar='+userInfo.avatar+'&nickname='+userInfo.nickname">
					<view class="acea-row row-middle">
						<text class="iconfont icon-tuijianren"></text>
						<view class="title">我要推荐给朋友</view>
					</view>
					<u-icon name="arrow-right" color="#9C9C9C"></u-icon>
				</navigator>
				<navigator class="line acea-row row-between-wrapper" url="/pages/user/partner_form"
					v-if="userInfo.partner_status == 0">
					<view class="acea-row row-middle">
						<text class="iconfont icon-hehuoren"></text>
						<view class="title">我要成为合伙人</view>
					</view>
					<u-icon name="arrow-right" color="#9C9C9C"></u-icon>
				</navigator>
				<navigator class="line acea-row row-between-wrapper" :url="'/pages/user/wxcode?id='+userInfo.id">
					<view class="acea-row row-middle">
						<text class="iconfont icon-hehuoren"></text>
						<view class="title">绑定微信</view>
					</view>
					<u-icon name="arrow-right" color="#9C9C9C"></u-icon>
				</navigator>
				<navigator class="line acea-row row-between-wrapper" url="/pages/user/evaluate_list">
					<view class="acea-row row-middle">
						<text class="iconfont icon-pingjia-tianchong"></text>
						<view class="title">我的评价</view>
					</view>
					<u-icon name="arrow-right" color="#9C9C9C"></u-icon>
				</navigator>
				<navigator class="line acea-row row-between-wrapper" url="/pages/user/news/list">
					<view class="acea-row row-middle">
						<text class="iconfont icon-tongzhifill"></text>
						<view class="title">平台动态</view>
						<view class="num" v-if="userInfo.notice_num > 0"> {{userInfo.notice_num}} </view>
					</view>
					<u-icon name="arrow-right" color="#9C9C9C"></u-icon>
				</navigator>
				<navigator class="line acea-row row-between-wrapper" url="/pages/user/opinion">
					<view class="acea-row row-middle">
						<text class="iconfont icon-yijianfankui"></text>
						<view class="title">意见反馈</view>
					</view>
					<u-icon name="arrow-right" color="#9C9C9C"></u-icon>
				</navigator>
				<button open-type="contact" class="line acea-row row-between-wrapper">
					<view class="acea-row row-middle">
						<text class="iconfont icon-10"></text>
						<view class="title">联系客服</view>
					</view>
					<u-icon name="arrow-right" color="#9C9C9C"></u-icon>
				</button>
			</view>
		</view>
		<login :isAuto="true" ref="mySon" @phone_show="phone_show"></login>
		<phone :isShow="isShow2" @close="close2"></phone>
		<!-- 提示 -->
		<u-toast ref="uToast"></u-toast>
	</view>
</template>

<script>
	let app = getApp();
	export default {
		data() {
			return {
				parameter: {
					'navbar': '1',
					'return': '0',
					'title': '陪诊服务',
					'color': true,
					'class': 'shop'
				},
				imageUrl: this.imageUrl,
				userInfo: '',
				isShow: false,
				isShow2: false,
				order_list: [{
					pic: '/static/images/order1.png',
					title: '待支付',
					order_status: 0,
					state: 1,
				}, {
					pic: '/static/images/order2.png',
					title: '已支付',
					order_status: 1,
					state: 2,
				}, {
					pic: '/static/images/order3.png',
					title: '待评价',
					order_status: 2,
					state: 3,
				}, {
					pic: '/static/images/order4.png',
					title: '已完成',
					order_status: 3,
					state: 4,
				}, ],
			};
		},
		onLoad() {
			
		},
		onShow() {
			this.userInfos();
		},
		/**
		 * 用户点击右上角分享
		 */
		onShareAppMessage: function() {

		},
		onShareTimeline(res) { //分享到朋友圈

		},
		methods: {
			async userInfos() {
				const res = await this.$myRequest({
					url: '/api/user/userInfo',
					data: {
						openid: uni.getStorageSync('openid')
					}
				})
				this.userInfo = res.data.data;
				console.log(this.userInfo);
			},
			chamgs() {
				this.$refs.mySon.login();
			},
			phone_show() {
				this.isShow2 = true;
			},
			close2() {
				this.isShow2 = false
				this.userInfos();
			},
			toOrder(item) {
				console.log(item)
				uni.switchTab({
					url: '/pages/order/list'
				})
				app.globalData.order_status = item.order_status;
				app.globalData.order_state = item.state;
			},
			toSet() {
				uni.navigateTo({
					url: '/pages/user/user_info?avatar=' + this.userInfo.avatar + '&nickname=' + this.userInfo
						.nickname + '&age=' + this.userInfo.age +
						'&gender=' + this.userInfo.gender + '&city=' + this.userInfo.city + '&province=' + this
						.userInfo.province + '&isUser=' + 1
				})
			},
			applyForm(num){
				if(num==1){
					this.$refs.uToast.show({
						type: 'success',
						message: '申请中，请等待电话审核！'
					})
				}else if(num==2){
					this.$refs.uToast.show({
						type: 'error',
						message: '申请失败，请联系客服！'
					})
				}
			}
		}
	}
</script>

<style lang="scss">
	.wap {
		padding: 0 30rpx;
		position: relative;
		background-color: #F6F6F6;
		min-height: 100vh;
	}

	.user {
		position: relative;
		z-index: 2;
	}

	.user .header {
		color: #000406;
		width: 100%;
	}

	.user .header .pictrue {
		width: 100rpx;
		height: 100rpx;
	}

	.user .header .pictrue image {
		width: 100%;
		height: 100%;
		border-radius: 50%;
		border: 2px solid #fff;
		box-sizing: border-box;
	}

	.user .header .name {
		font-size: 32rpx;
		margin-left: 20rpx;
	}

	.user .header .iconfont {
		font-size: 32rpx;
		margin-right: 10rpx;
	}

	.nav {
		padding: 30rpx 0;
	}

	.nav .item {
		flex: 1;
		text-align: center;
		font-size: 26rpx;
		color: #000406;
	}

	.nav .item .num {
		font-size: 32rpx;
		padding-bottom: 20rpx;
	}

	.box {
		background-color: #fff;
		border-radius: 12rpx;
		padding: 30rpx;
		margin-bottom: 30rpx;
	}

	.myOrder .title-line {
		margin-bottom: 20rpx;
	}

	.myOrder .title-line .allOrder {
		color: #9C9C9C;
	}

	.myOrder .item {
		width: 20%;
		text-align: center;
	}

	.myOrder .item .pictrue {
		height: 80rpx;
	}

	.myOrder .item .pictrue image {
		width: 50rpx;
		height: 50rpx;
	}

	.line {
		height: 100rpx;
		border-bottom: 1px solid #F2F2F2;
		font-size: 28rpx;
	}


	.line .iconfont {
		width: 36rpx;
		margin-right: 20rpx;
		color: #1F83FF;
		font-size: 36rpx;
		text-align: center;
	}

	.line .num {
		padding: 0 12rpx;
		height: 30rpx;
		background: #FE8802;
		border-radius: 20rpx;
		margin-left: 20rpx;
		color: #fff;
		font-size: 24rpx;
		line-height: 30rpx;
	}
</style>
